﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;
using TSL_Tools.SqlTools;
using ReportingEngine;
using System.IO;
using Xceed.Wpf.Toolkit.PropertyGrid;

namespace VSLT_Reporting
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Loads the given file into the RichTextBox and sets that tab to be the active tab.
        /// </summary>
        /// <param name="helpFileName">The name of the file to load</param>
        /// <param name="helpFileType">The filetype (extension) of the file. Example:  '.rtf'</param>
        private void LoadHelpFile(string helpFileName, string helpFileType)
        {
            string str;
            string fileName = helpFileName;

            using (StreamReader sr = new StreamReader(fileName))
            {
                str = sr.ReadToEnd();
            }
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            MemoryStream ms = new MemoryStream(encoding.GetBytes(str));
            
            TextRange text = new TextRange(rtbResults.Document.ContentStart, rtbResults.Document.ContentEnd);
            
            if (helpFileType == ".rtf")
                text.Load(ms, System.Windows.DataFormats.Rtf);
            else if (helpFileType == ".xaml")
                text.Load(ms, System.Windows.DataFormats.Xaml);
            else
                MessageBox.Show(Msg_TSSL_ERROR_DATAFORMAT);

            tabRichTextBox.IsSelected = true;
        }

        private void InitializeHelpFileTopics()
        {
        }

        private void ChangeDisplayedHelpTopic()
        {
            int x = lvHelpTopics.SelectedIndex;
            switch (x)
            {
                case 0:
                    LoadHelpFile("HelpFiles\\00_Getting Started.rtf", ".rtf"); break;
                case 1:
                    LoadHelpFile("HelpFiles\\01_Editing DefaultChartingObjects.rtf", ".rtf"); break;
                case 2:
                    LoadHelpFile("HelpFiles\\01_Editing ExtendedSettings.rtf", ".rtf"); break;
                case 3:
                    LoadHelpFile("HelpFiles\\02_Main Screen.rtf", ".rtf"); break;
                case 4:
                    LoadHelpFile("HelpFiles\\02_SQL Changes.rtf", ".rtf"); break;
                case 5:
                    LoadHelpFile("HelpFiles\\03_Ribbon_Options.rtf", ".rtf"); break;
                case 6:
                    LoadHelpFile("HelpFiles\\04_Ribbon_Home.rtf", ".rtf"); break;
                case 7:
                    LoadHelpFile("HelpFiles\\05_Ribbon_Tables.rtf", ".rtf"); break;
                case 8:
                    LoadHelpFile("HelpFiles\\06_Ribbon_Charts.rtf", ".rtf"); break;
                case 9:
                    LoadHelpFile("HelpFiles\\07_Ribbon_Perfmon.rtf", ".rtf"); break;
                case 10:
                    LoadHelpFile("HelpFiles\\08_Sample_UpdateDB.rtf", ".rtf"); break;
                case 11:
                    LoadHelpFile("HelpFiles\\09_Sample_SummaryResults.rtf", ".rtf"); break;
                case 12:
                    LoadHelpFile("HelpFiles\\10_Sample_BuildReport.rtf", ".rtf"); break;
                case 13:
                    LoadHelpFile("HelpFiles\\11_Sample_Scenario_RunInfo.rtf", ".rtf"); break;
                case 14:
                    LoadHelpFile("HelpFiles\\12_Sample_Database_Information.rtf", ".rtf"); break;
                case 15:
                    LoadHelpFile("HelpFiles\\HelpFile_ResultsDifferences.rtf", ".rtf"); break;
                case 16:
                    LoadHelpFile("HelpFiles\\HelpFile_ResultsStorage.rtf", ".rtf"); break;
                case 17:
                    LoadHelpFile("HelpFiles\\HelpFile_WarmupCooldown.rtf", ".rtf"); break;
            }
        }
    }
}



